﻿@using Covenant.Core
@using Covenant.Models.Grunts
@model GruntTasking
@{
    Layout = "_GruntTaskingLayout";
    ViewData["Title"] = "Grunts";
}
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap pb-2 mb-3">
    <h1 class="h2">GruntTasking: <span id="tasking-name" class="text-primary">@Html.DisplayFor(model => model.Name)</span></h1>
</div>

<div class="form-row">
    <div class="form-group col-md-4">
        <label asp-for="Name"></label>
        <input asp-for="Name" value="@Model.Name" class="form-control" readonly>
    </div>
    <div class="form-group col-md-4">
        <label asp-for="Grunt.Name">Grunt</label>
        <form asp-controller="Grunt" asp-action="Interact" asp-route-id="@Model.Grunt.Id" method="get">
            <button type="submit" class="btn btn-secondary bg-light text-dark text-left w-100">@Html.DisplayFor(model => model.Grunt.Name)</button>
        </form>
    </div>
    <div class="form-group col-md-4">
        <label asp-for="GruntTask.Name">Task</label>
        <form asp-controller="GruntTask" asp-action="Edit" asp-route-id="@Model.GruntTask.Id" method="get">
            <button type="submit" class="btn btn-secondary bg-light text-dark text-left w-100">@Html.DisplayFor(model => model.GruntTask.Name)</button>
        </form>
    </div>
</div>
<div class="form-row">
    <div class="form-group col-md-4">
        <label asp-for="Status"></label>
        <select asp-for="Status" asp-items="Html.GetEnumSelectList<GruntTaskingStatus>()" class="form-control" disabled></select>
    </div>
    <div class="form-group col-md-4">
        <label for="GruntCommand_CommandTime">CommandTime</label>
        <input id="GruntCommand_CommandTime" name="GruntCommand_CommandTime" value="@Html.DisplayFor(model => model.GruntCommand.CommandTime)" class="form-control" readonly>
    </div>
    <div class="form-group col-md-4">
        <label asp-for="Type"></label>
        <select asp-for="Type" asp-items="Html.GetEnumSelectList<GruntTaskingType>()" class="form-control" disabled></select>
    </div>
</div>
<div class="form-row">
    <div class="form-group col-md-4">
        <label asp-for="GruntCommand.User.UserName"></label>
        <input asp-for="GruntCommand.User.UserName" value="@Model.GruntCommand.User.UserName" class="form-control" readonly>
    </div>
    <div class="form-group col-md-8">
        <label asp-for="GruntCommand.Command"></label>
        <textarea asp-for="GruntCommand.Command" value="@Model.GruntCommand.Command" rows="1" class="form-control" readonly></textarea>
    </div>
</div>
@for (int i = 0; i < Math.Min(Model.GruntTask.Options.Count, Model.Parameters.Count); i++)
{
    <div class="form-group">
        <label asp-for="Parameters[i]">@Model.GruntTask.Options[i].Name</label>
        <input asp-for="Parameters[i]" value="@Model.Parameters[i]" class="form-control" readonly>
    </div>
}
<div class="form-group">
    <label asp-for="GruntCommand.CommandOutput.Output"></label>
    @if (Model.GruntTask.Name == "ScreenShot")
    {
        <img style="max-width:100%" src="data:image/png;base64, @Model.GruntCommand.CommandOutput.Output" />
    }
    else
    {
        <textarea asp-for="GruntCommand.CommandOutput.Output" value="@Model.GruntCommand.CommandOutput.Output" rows="20" class="form-control" readonly></textarea>
    }
</div>

@section Scripts {

}